package com.king01.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.king01.dao.InlibraryDao;
import com.king01.entity.Inlibrary;
import com.king01.entity.Staff;
import com.king01.service.InlibraryService;
import com.king01.vo.BranchVo;
import com.king01.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.List;

/**
 * @author ：lqs
 * @date ：Created in 2023/9/26 17:33
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class InlibraryServiceImpl implements InlibraryService {
    @Autowired
    private InlibraryDao inlibraryDao;
    @Autowired
    private HttpSession session;

    //查询入库消息主表
    @Override
    public Result findInStorageDao(Integer currentPage, Integer pageSize, BranchVo branchVo) {
        //mybatis-pageHelper插件
        PageHelper.startPage(currentPage,pageSize);
        Staff staff = (Staff)session.getAttribute("staff");
        if (staff.getStaffid()!=111){
            branchVo.setBranchid(staff.getBranchid());
        }
        List<Inlibrary> inStorageDao = inlibraryDao.findInStorageDao(branchVo);

        //把查询的结果封装PageInfo对象中
        PageInfo<Inlibrary> pageInfo=new PageInfo<>(inStorageDao);
        return new Result(200,"查询库信息的主表成功",pageInfo);
    }

    @Override
    public Result updateInlibrary(Integer id) {
        Date date = new Date();
        Integer integer = inlibraryDao.updateInlibrary(id,date);
        return new Result(200,"入库审核修改状态",integer);
    }
    //修改驳回后的InlibraryDao
    @Override
    public Result updateRemark(Integer id, String remark) {
        Date date = new Date();
        Integer integer = inlibraryDao.updateRemark(id, remark,date);
        return new Result(200,"修改驳回后的数据成功",integer);
    }
}

